<?php
class Zend_View_Helper_LoadSkin extends Zend_View_Helper_Abstract{
	public function loadSkin($skin){
		$frontController = Zend_Controller_Front::getInstance();
		$module = $frontController->getRequest()->getModuleName();
		//echo $module;
		if($module=="admin"){
			//echo $module;
			$skinData =  new Zend_Config_Xml(realpath(PUBLIC_PATH."/admin/skin.xml"));	
		}else{
			//echo "abc";
			$skinData =  new Zend_Config_Xml(realpath(PUBLIC_PATH."/skins/".$skin."/skin.xml"));	
		}
		
		$stylesheets = $skinData->stylesheets->stylesheet->toArray();
		
		//append each stylesheet to headlink
		if(is_array($stylesheets)){
			foreach($stylesheets as $stylesheet){
				if($module == "admin"){
					$this->view->headLink()->appendStylesheet(PUBLIC_URL."/admin/css/".$stylesheet);
				}else{
					$this->view->headLink()->appendStylesheet(PUBLIC_URL."/skins/".$skin."/css/".$stylesheet);
				}
				
			}
		}
	}
}
?>